<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<script>
	var ctx = "${ctx}";
</script>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords"
	content="">
<meta name="description"
	content="">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT">
<link rel="shortcut icon" href="favicon.ico">
	<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/animate.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/style.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/common.css?v=${static_version}" rel="stylesheet" />
	<link href="//at.alicdn.com/t/font_9x03jhokyws9vn29.css" rel="stylesheet">
<title>优惠券管理</title>
</head>
		
<body class="gray-bg">
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="ibox float-e-margins">
	 		<div class="ibox-title">
            	<h5>优惠券管理<small></small></h5>
            </div>		
            
			<div class="ibox-content">
				<div class="row">
				<form class="form-group" id="member_table_form">			
					<div class="col-md-3">
						<div class="input-group">
							<span class="input-group-addon">优惠券类型：</span>
							<select name="coupon_cate_id"
								class="form-control">
								<option value="-1">--全部--</option>								
								<c:forEach items="${match_classifys_list}" var="classifys">
								<option value="${classifys.item_value}" 
									<c:if test="${coupon_cate_id==classifys.item_value}">selected</c:if>>${classifys.display_name}
								</option>					
								</c:forEach>	
							</select>
						</div>
					</div>						
					<div class="col-md-3">
						<div class="input-group">
							<span class="input-group-addon">优惠类型：</span>
							<select name="coupon_type"
								class="form-control">
								<option value="-1">--全部--</option>								
								<c:forEach items="${match_preferentias_list}" var="preferentias">
								<option value="${preferentias.item_value}" 
									<c:if test="${coupon_type==preferentias.item_value}">selected</c:if>>${preferentias.display_name}
								</option>					
								</c:forEach>
							</select>
						</div>
					</div>		
					<div class="col-md-1 col-sm-1">
						<button name="" id="" class="btn btn-primary radius" type="submit">搜索</button>								
					</div>
					
					<div class="col-md-1">
						<a class="btn btn-warning btn-outline radius" onclick="javascript:location.replace(location.href);"
						href="javascript:location.replace(location.href);">刷新</a> 
				    </div>	
				</form>
				</div>
	
			<table data-action="" data-datatable="true"  class="table table-striped table-bordered table-hover dataTables-example">
				<thead>
					<tr>	                       
                    	<th class="text-center">优惠券分类</th>                  
                        <th class="text-center">优惠类型</th>             
                        <th class="text-center">有效期至</th>
   					 	<th class="text-center">剩余数量</th>
                        <th class="text-center">押金金额</th>
                        <th class="text-center">状态</th>            
						<th class="text-center">操作</th>
					</tr>
				</thead>
				<tbody>
				<c:forEach items="${u_coupons}" var="u_coupon">					
					<tr class="text-c">								
                    	<td class="text-center">                      
			            	<input type="hidden" id="id" name="id" value='${u_coupon.coupon_id}'></input>
	                        <c:if test="${1==u_coupon.coupon_cate_id}">
	                        	购物
	                        </c:if>
	                        <c:if test="${0==u_coupon.coupon_cate_id}">
	                        	美食
	                        </c:if>
                        </td>                             
                        <td class="text-center">                       
                          	<c:if test="${u_coupon.coupon_type==1}">
                          		满减券
                          	</c:if> 
                 		    <c:if test="${u_coupon.coupon_type==2}">
                 		    	抵用券
                 		    </c:if>
                        </td>          
                        <td class="text-center">${u_coupon.end_time}</td>                          
                        <td class="text-center">${u_coupon.ext1}</td>
                        <td class="text-center">${u_coupon.deposit_amount}</td>
                        <td class="text-center">
                            <c:if test="${2==u_coupon.ext2}">
                            	进行中
                            </c:if>
                   			<c:if test="${1==u_coupon.ext2}">
                   				即将到期
                   			</c:if>
                   			<c:if test="${0==u_coupon.ext2}">
                   				已结束
                   			</c:if>
                        </td>
						<td class="td-manage text-center">
							<a class="btn btn-primary radius"
								onClick="u_coupon_edit(this,'${u_coupon.coupon_id}')" href="javascript:void(0);"
								title="编辑">编辑</a>
							&nbsp;&nbsp;&nbsp;&nbsp;
							<a class="btn btn-primary radius"
								onClick="u_coupon_delete(this,'${u_coupon.coupon_id}')" href="javascript:void(0);"
								title="删除">删除</a>
						</td>
					</tr>
				</c:forEach>
				</tbody>
				</table>
			</div>

		</div>
	</div>

	
	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/layer/layer.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/dataTables/jquery.dataTables.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/dataTables/dataTables.bootstrap.js?v=${static_version}"></script>

	<script type="text/javascript">
		$(function() {
			$('.table-sort').dataTable({
				"aaSorting" : [ [ 0, "desc" ] ],//默认第几个排序
				"bStateSave" : true,//状态保存
				"aoColumnDefs" : [
				//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
				{
					"orderable" : false,
					"aTargets" : [ 1, 2 ]
				} // 制定列不参与排序
				]
			});				
			
		});

		/*删除*/
		function u_coupon_delete(obj,id){
			layer.confirm('确认删除？', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "${ctx}/coupon-delete",
					data : "id=" + id,
					error : function() {
						layer.msg('操作失败', {icon:5,time:1000});
					},
					success : function(msg) {
						layer.msg('已删除 ', {icon:6,time:1000});
						location.href ="${ctx}/coupon-list"; 
					}
				});
			},
			function(){
				layer.msg('未删除', {icon:5,time:1000});
			});	
		}
		
		
		function u_coupon_edit(obj,id,w,h){
			var edit_page = "${ctx}/coupon-add-pre?id="+id;
			var index = layer.open({
				type: 2,
				title: "编辑",
				content: edit_page
			});
			layer.full(index);
		}
				
	</script>
</body>
</html>



